package ru.jexp.rcp.supply.beans.d18;

import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

import ru.jexp.rcp.supply.beans.project.dvs.sostavizdelia.TreePathMerge;

public class D18SostavIzdeliaContentProvider implements ITreeContentProvider
{

	@Override
	public void dispose()
	{

	}

	@Override
	public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
	{
	}

	@Override
	public Object[] getElements(Object inputElement)
	{
		if (inputElement instanceof TreePathMerge)
		{
			return getChildren(inputElement);
		}	
		return new TreePathMerge[0];
	}

	@Override
	public Object[] getChildren(Object parentElement)
	{
		TreePathMerge merge = (TreePathMerge)parentElement;
		return merge.getChildren().toArray(new TreePathMerge[]{});
	}

	@Override
	public Object getParent(Object element)
	{
		TreePathMerge merge = (TreePathMerge)element;
		return merge.getParent();
	}

	@Override
	public boolean hasChildren(Object element)
	{
		TreePathMerge merge = (TreePathMerge)element;
		return !merge.getChildren().isEmpty();
	}

}
